#pragma once

#include <stdio.h>
#include <string>
#include <string.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>
#include "ThreadPool.hpp"
#include "FileOpt.h"
#include <memory>
using namespace std;

class TcpServerThreadPool{
private:
    int server_fd;
    //char ip_addr[100];
    int port;
    string server_ip;
    int link_max;
    // int new_socket;
    int objcreat_errflag;
    int link_success;
    struct sockaddr_in address;
    shared_ptr<FileOpt> m_fileOpt;
    ThreadPool m_threadPool_;

public:
    void deal_client(int );

    ~TcpServerThreadPool();
    explicit TcpServerThreadPool(shared_ptr<FileOpt>,const string& ip, int l_port,int l_link_max, int& ret);
    int wait_tcp_link();
    int s_read(int socket,char* buffer,int len);
    int s_write(int socket,char* buffer,int len);
};